import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { TabsPage } from '../pages/tabs/tabs';
import { JPush } from '@jiguang-ionic/jpush'

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = TabsPage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, jpush: JPush) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();

      document.addEventListener('resume', () => { // 进入前台
        window.sessionStorage.removeItem('backstage')
      });

      document.addEventListener('pause', (() => { // 进入后台
        window.sessionStorage.setItem('backstage', '1')
      }));

      jpush.init()
      jpush.setDebugMode(true)

      console.log('%c platform.ready() has been executed.', 'color:#fa6470')
    });
  }
}
